<template>

  <div class="Collection">
    <van-sticky>
      <van-row class="all-select">
        <van-col span="7" v-for="(item, index) in tabList" :key="index"
          :class="formData.tabActive == index ? 'tabactive fadenum' : ''" @click="getmenu(item.id, index, item.type)">
          <span>{{ item.name }}</span>
          <div v-if="item.name">
            <img src="@/assets/image/icon/last.png" alt="" class="upper">
            <img src="@/assets/image/icon/nexxt.png" alt="" class="lower">
          </div>
        </van-col>
      </van-row>
      <van-row class="select-item" v-if="formData.seabhidden">
        <van-col v-for="(item, index) in selectlist" :key="index" class="item">
          <!-- <span  " @click="getmore(item.id,index)">{{item.collection.name}}</span> -->
          <div class="span" :class="formData.itemActive == item.id ? 'selectactive' : ''" @click="getmore(item.id)">
            {{ item.name }}</div>
        </van-col>
      </van-row>
      <form action="/" v-else>
        <van-search v-model="formData.keywords" show-action placeholder="请输入搜索关键词" @search="onSearch"
          @cancel="onCancel">
          <template #left-icon>
            <img src="@/assets/image/icon/seach.png" alt="">
          </template>
        </van-search>
      </form>
    </van-sticky>
  </div>
  <van-list v-model:loading="formData.loading" :finished="formData.finished" @load="onLoad" finished-text="我是有底线的~">
    <div class="clendar" v-for="(item, index) in Contentlist" :key="index">
      <h2>{{ transformTimestamp(item.startTime) }}</h2>
      <van-row>
        <van-col span="8" class="clendar-img">
          <div class="videoContainer" @click="GoInner(item.id)" v-if="!VideoIndexOf(item.collection.cover)">
            <!-- <vdeo :src="item.collection.cover" /> -->
            <vdeo :collection='item.collection.cover' class="video" />
          </div>
          <div class="img-box" :style="'background-image:url(' + item.collection.cover + ') '"
            v-if="VideoIndexOf(item.collection.cover)" @click="GoInner(item.id)"></div>
        </van-col>
        <van-col span="16">
          <div class="cont">
            <p>{{ item.collection.name }}</p>
            <div class="Limit-warp">
              <span>限量</span>
              <span>{{ item.collection.totalNumber ? item.collection.totalNumber : "0" }}份</span>
            </div>
            <div class='txt'>{{ item.collection.className ? item.collection.className : "" }}</div>
          </div>
        </van-col>
        <div class="linercolor">￥ {{ item.amount }}</div>
        <!-- <van-col class="linercolor" span="6"> ￥ {{item.price}}
        </van-col> -->
      </van-row>

    </div>
    <van-empty :image="require('@/assets/image/none.png')" description="暂无数据" v-if="formData.loading" />
  </van-list>
</template>
<script>
import { ref, defineComponent, reactive, onMounted, toRefs, nextTick } from "vue";
import { saleCollection, drawCollection, onlineCollection } from "@/api/public";
import { formMonth, VideoIndexOf, countTime, transformTimestamp } from "@/utils/phone";
import { useRouter } from "vue-router"
import { Toast } from "vant";
import { useStore } from "vuex";
import vdeo from "@/components/video.vue";
export default defineComponent({
  components: { vdeo },
  props: {
    menulist: {
      type: Array
    }
  },
  setup(props) {
    const formData = reactive({
      sellType: "0",
      propType: 0,
      pageNum: 1,
      pageSize: 1,
      total: 0,
      finished: false,
      loading: true,
      seabhidden: false,
      rankShow: false,
      itemActive: null,
      tabActive: 0,
      grid: 1,
      keywords: ""
    })
    onMounted(() => {
    })

    const onLoad = async () => {
      const data = {
        pageSize: formData.pageSize,
        pageNum: formData.pageNum,
      }
      const res = await onlineCollection(formData)
      formData.loading = false
      formData.pageNum++
      formData.total = res.data.data.total
      Contentlist.value = Contentlist.value.concat(res.data.data.records)
      if (formData.total <= Contentlist.value.length) {
        formData.finished = true;
        console.log('不加载')
      }
      formData.loading = false
    }
    const Contentlist = ref([
      // {
      //   image: require('@/assets/image/product.png'),
      //   name: "熊猫系列"
      // }, { image: require('@/assets/image/product.png') },
      // { image: require('@/assets/image/product.png') }, { image: require('@/assets/image/product.png') }
      // , { image: require('@/assets/image/product.png') }
    ])
    const selectlist = reactive([
      { id: 1, name: "全部时间" },
      { id: 2, name: "时间升序" },
      { id: 3, name: "时间倒序" },
    ])
    const tabList = reactive([
      { id: 1, name: "全部时间" }
    ])
    const onSearch = () => {

    }
    const onCancel = () => {

    }
    const getmore = (id) => {
      formData.itemActive = id
      formData.pageNum = 1
      Contentlist.value = []
      const data = {
        sell: 1,
        pageSize: formData.pageSize,
        pageNum: formData.pageNum,
      }
      onLoad()
    }
    const rangk = () => {
      formData.seabhidden = false
      formData.rankShow = !formData.rankShow
      if (formData.rankShow) {
        formData.grid = 1
      } else {
        formData.grid = 2
      }
    }
    const getmenu = (id, index, type) => {

      formData.seabhidden = !formData.seabhidden
      formData.tabActive = index
      const data = {
        sell: 1,
        pageSize: formData.pageSize,
        pageNum: formData.pageNum,
      }

    }
    return {
      VideoIndexOf, formData, selectlist, tabList, getmore, getmenu, rangk, Contentlist, onSearch, onCancel, onLoad, transformTimestamp, countTime
    }

  }

})
</script>
<style lang="less" scoped>
.videoContainer {
  overflow: hidden;
  border-radius: 20px 20px 0px 0px;
  border: 1px solid #ffffff;

  .fullscreenVideo {
    width: 100%;
    height: 200px;
  }

  video {
    width: 100%;
    height: 200px;
  }
}

.clendar {
  position: relative;
  margin: 39px 21px 0px;
  border-radius: 20px;
  padding: 20px 20px;
  background: linear-gradient(0deg, #0e1011, #222222);

  h2 {
    margin: 0px;
    font-size: 32px;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #ffffff;
    line-height: 53px;
  }

  .clendar-img {
    margin-top: 20px;
    background: linear-gradient(0deg, #161718, #4b4c4d);
    border-radius: 20px;
    overflow: hidden;

    .img-box {
      width: 100%;
      height: 200px;
      background-size: cover;
      background-repeat: no-repeat;
      background-position: center center;
    }
  }

  .linercolor {
    bottom: 20px;
    right: 20px;
    position: absolute;
    text-align: right;
    font-size: 40px;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #ffffff;
    line-height: 73px;
    display: flex;
    align-items: flex-end;
    background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .cont {
    margin-left: 40px;

    p {
      font-size: 32px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #ffffff;
      line-height: 53px;
      margin-top: 30px;
    }

    .txt {
      font-size: 26px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #b9c4c7;
      line-height: 48px;
    }

    .Limit-warp {
      margin: 10px 0;

      span {
        font-size: 26px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        line-height: 48px;
      }

      span:nth-child(1) {
        color: #444442;
        font-size: 26px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        background: #f3e3bb;
        border-radius: 4px 0px 0px 4px;
        padding: 3px 12px;
      }

      span:nth-child(2) {
        padding: 3px 12px;
        background: #444442;
        border-radius: 4px;
        font-size: 26px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #f3e3bb;
        line-height: 48px;
      }
    }
  }
}

.img-box {
  img {
    width: 27px;
    vertical-align: middle;
    margin-right: 5px;
  }

  .time-warp {
    color: #169900;
  }

  .seld-warp {
    color: #b9c4c7;
  }

  .light-warp {
    color: #ea0026;

    img {
      width: 17px;
      height: 24px;
    }
  }

  .warp {
    align-items: center;
    padding: 10px 20px;
    margin: 10px 12px 0px;
    background: #000000;
    border-radius: 26px;
    display: flex;
    width: fit-content;
  }
}

&:deep(.van-search) {
  background: #202123;
}

&:deep(.van-field) {
  margin-bottom: 0px;
  background: transparent;
  height: auto;
}

&:deep(.van-search__action) {
  font-size: 30px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #b9c4c7;
  line-height: 18px;
}

&:deep(.van-search__content--square) {
  width: 628px;
  height: 68px;
  background: #282a2c;
  border-radius: 34px;
  padding-left: 20px;

  img {
    width: 32px;
    height: 32px;
    line-height: 68px;
    margin-left: 10px;
    margin-top: 6px;
  }
}

&:deep(.van-sticky--fixed) {
  background: #282a2c;
  height: auto !important;
}

&:deep(.van-hairline--top) {
  margin: 0px 10px;
  //   background: #161718;
  //   width: 94%;
  //   margin: 30px auto;
  border: none;
}

&:deep(.van-hairline--top:after) {
  border-top-width: 0px;
}

&:deep(.van-grid-item__content) {
  padding: 30px 0px 0px;
  background: transparent;
}

&:deep(.van-hairline:after) {
  border: none;
}

&:deep(.van-grid-item) {
  background: transparent;
}

.all-select {
  margin-top: 30px;
  background: #282a2c;
  padding: 26px 21px;
  display: flex;

  &:deep(.van-col) {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;

    span {
      font-size: 30px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #ffffff;
      line-height: 30px;
    }

    img {
      width: 28px;
      height: 16px;
      margin-left: 10px;
    }
  }

  .rank {
    img {
      width: 48px;
      height: 48px;
    }
  }

  .upper {
    display: none;
    // transform: rotate(360deg);
    // transform: rotate(90deg);
  }

  .lower {
    display: block;
  }

  @keyframes masked-animation {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  @keyframes opacity-animation {
    0% {
      opacity: 0;
    }

    100% {
      opacity: 1;
    }
  }

  .tabactive {
    span {
      font-size: 30px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #3d94ff;
      line-height: 30px;
      background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .upper {
      display: block !important;
      animation: masked-animation 0.5s;
      -webkit-animation: masked-animation 0.5s;
      transform: rotate(360deg);
    }

    .lower {
      animation: masked-animation 1s linear;
      -webkit-animation: masked-animation 1s linear;
      display: none !important;
    }
  }
}

.select-item {
  display: flex;
  overflow-y: scroll;
  flex-wrap: nowrap;
  width: 100%;

  .selectactive {
    background: #282a2c;
    border: 1px solid #ffffff !important;
    color: #ffffff;
  }

  .span {
    min-width: fit-content;
    text-align: center;
    margin-top: 30px;
    padding: 22px 36px;
    background: #282a2c;
    border-radius: 34px;
    font-size: 28px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #b9c4c7;
    margin-left: 20px;
  }

  span {
    display: block;
    box-sizing: content-box;
    white-space: normal;
    width: fit-content !important;
    word-wrap: none;
    text-align: center;
    margin-top: 30px;
    padding: 22px 36px;
    // display: block;
    background: #282a2c;
    border-radius: 34px;
    font-size: 28px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #b9c4c7;
    // line-height: 18px;
    margin-left: 20px;
  }
}
</style>